package com.bilicraft.plugin.kexue;



import java.io.File;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

import com.bilicraft.plugin.kexue.event.ListenerBlock;
import com.bilicraft.plugin.kexue.event.ListenerPlayer;
import com.bilicraft.plugin.kexue.jsonapi.JSONAPIActivator;
import com.bilicraft.plugin.kexue.utils.BBSConfig;
import com.bilicraft.plugin.kexue.utils.ExTimer;


public class BiliBlackScience extends JavaPlugin{
	
	public String curdir = "./";
	
	@Override
    public void onEnable(){
    	this.getLogger().info("BiliBlackScience enable.");
    	reloadConfiguration();
    	JSONAPIActivator.act();
    	regEventHandlers();
    	ExTimer.getTimer();
    }
	@Override
    public void onDisable() {
    	this.getLogger().info("BiliBlackScience down.");
    }
	@Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
		return CommandParser.cmd(sender, cmd, label, args);
	}

	public void regEventHandlers(){
		getServer().getPluginManager().registerEvents(new ListenerBlock(), this);
		getServer().getPluginManager().registerEvents(new ListenerPlayer(), this);
	}
	
	public void reloadConfiguration(){
		if (!new File(getDataFolder(), "config.yml").exists()) {
			this.saveDefaultConfig();
		}
		reloadConfig();
		BBSConfig.getInstance().setAll(getConfig());
	}
}
